// pages/publish_address/publish_address.js
Page({

  data: {
    haveAddress:false,
    address:'',
    detailAddress:'',
  },



  // 得到地址
  getAddress(e){
    // console.log(e);
    const temp = e.detail.value.join('');
    this.setData({
      haveAddress:true,
      address:temp
    })
  },

  // 得到input框的value值
  getInput(e){
    console.log(e);
    this.setData({
      detailAddress:e.detail.value
    })

  },

  // 返回上一页
  navBackTo(){
    if(!this.data.address || !this.data.detailAddress){
      wx.showModal({
        title: '提示',
        content: '省市区、详细地址为必填项',
        showCancel: false,
        confirmText: '确定',
        confirmColor: '#3CC51F',
      });
    }else{
      const tempData = {
        province:this.data.address,
        detailAddress:this.data.detailAddress
      }
      wx.setStorageSync('addressData', tempData);
      wx.switchTab({
        url: '/pages/publish/publish',
      });
    }
  }
})